import NProgress from 'nprogress'; // progress bar
import router from '@/router';
import '@/assets/css/nprogress.less';
import setDocumentTitle from '@/utils/dom-util';

// 控制进度条
const topProgress = true;

if (topProgress) {
  NProgress.configure({ showSpinner: false }); // NProgress Configuration
}

router.beforeEach(async (to, from, next) => {
  if (topProgress) NProgress.start(); // start progress bar
  // 设置页面标题
  setDocumentTitle(to.meta);
  next();
});

router.afterEach(() => {
  if (topProgress) NProgress.done(); // finish progress bar
});
